//
//  LTMainTabBar.m
//  weiboOC
//
//  Created by 刘涛 on 15/6/24.
//  Copyright © 2015年 tao6. All rights reserved.
//

#import "LTMainTabBar.h"

@interface LTMainTabBar ()

@property (nonatomic, strong) UIButton *compostBtn;

@end

@implementation LTMainTabBar




- (void)layoutSubviews {
    [super layoutSubviews];
    
    static float buttonCount = 5;
    
    float w = self.bounds.size.width / buttonCount;
    
    float h = self.bounds.size.height;
    
    CGRect rect = CGRectMake(0, 0, w, h);
    
    int index = 0;
    
    for (UIView *v in self.subviews) {
        if ([v isKindOfClass:[UIControl class]] && ![v isKindOfClass:[UIButton class]]) {
            v.frame = CGRectOffset(rect, w * index, 0);
            index += index == 1 ? 2 : 1;
        }
    }
    
    self.compostBtn.frame = rect;
    self.compostBtn.center = CGPointMake(self.center.x, self.bounds.size.height * 0.5);
    
}




- (UIButton *)compostBtn {
    if (_compostBtn == nil) {
        _compostBtn = [[UIButton alloc] init];
        
        [_compostBtn setImage:[UIImage imageNamed:@"tabbar_compose_icon_add"] forState:UIControlStateNormal];
        [_compostBtn setImage:[UIImage imageNamed:@"tabbar_compose_icon_add_highlighted"] forState:UIControlStateHighlighted];
        [_compostBtn setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button"] forState:UIControlStateNormal];
        [_compostBtn setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button_highlighted"] forState:UIControlStateHighlighted];
        
        [self addSubview:_compostBtn];
    }
    return _compostBtn;
}

@end
